package HuaWei;


import java.util.Scanner;

public class HuaWei01 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            int w = sc.nextInt();
            int h = sc.nextInt();
            int x = sc.nextInt();
            int y = sc.nextInt();
            int sx = sc.nextInt();
            int sy = sc.nextInt();
            int t = sc.nextInt();
            int[][] arr = new int[h][w];
            for (int i = 0; i < h; i++) {
                String next = sc.next();
                for (int j = 0; j < w; j++) {
                    arr[i][j] = Integer.parseInt(String.valueOf(next.charAt(j)));
                }
            }
            int sum = 0;
            if (w == 1 && h == 1) {
                // 就一个元素，不断弹
                sum = t * arr[0][0];
                System.out.println(sum);
                return;
            }
            for (int i = 0; i <= t; i++) {
                // 反弹
                sx = reverse(w, x, sx, i);
                sy = reverse(h, y, sy, i);
                sum += arr[y][x];
                // 坐标变化
                x = point(w, x, sx);
                y = point(h, y, sy);
            }
            System.out.println(sum);
        }
    }

    private static int point(int wh, int xy, int sxy) {
        if (wh > 1) {
            xy += sxy;
        }
        return xy;
    }

    private static int reverse(int wh, int xy, int sxy, int i) {
        // 反弹
        if (xy == 0 || xy == wh - 1) {
            if (i == 0) {
                if (xy == 0) {
                    sxy = 1;
                } else if (xy == wh - 1) {
                    sxy = -1;
                }
            } else {
                sxy = -sxy;
            }
        }
        return sxy;
    }
}
